home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / Gui4Cli / Dir / Dir.rep (.txt) < prev    next >
PC-File  |  1997-12-02  |  3KB  |  111 lines

  1. G4C   
  2. ; Dir.rep - GUI for the c:Rep replace command.
  3. ; ----------------- The window
  4. WinBig -1 -1 400 100 'Replace in selected files'
  5. WinType 11110001
  6. varpath dir.gc
  7. BOX    0 0 0 0 OUT ICONDROP
  8. ; ----------------- General events
  9. xOnLoad
  10. rp_from  = ""
  11. rp_to    = ""
  12. rp_savemode = OVER
  13. rp_ci = ""
  14. guiopen Dir.rep
  15. RUN 'resident guis:c/Rep pure add'
  16. xOnReload
  17. guiopen dir.rep
  18. xOnClose
  19. delvar rp_#?
  20. guiquit Dir.rep
  21. run 'resident Rep remove'
  22. ; ---------------- text-in gadgets for entering..
  23. xTextIn   80 5  310 18 'Replace:' rp_from "" 200    ; string to Rep
  24. gadid 1
  25. setgad dir.rep 2 on   ; activate next textin
  26. xTextIn   80 25 310 18 'With:' rp_to "" 200        ; Rep with this
  27. gadid 2
  28. ; ---------------- Do we want to add extensions to the files ?
  29. xCycler  10 45 190 14 "" rp_savemode
  30. gadid 3
  31. cstr 'OVERWRITE Files'    OVER
  32. cstr 'Add .rep extension' EXT
  33. ; ---------------- case insensitive search ?
  34. xCycler  200 45 190 14 "" rp_ci
  35. gadid 6
  36. cstr 'Case Sensitive'    ""
  37. cstr 'Case Insensitive'  I
  38. ; ---------------- A text display, telling you what's going on.
  39. TEXT 15 65 50 14 Status: 20 NOBOX
  40. TEXT 80 65 310 14 Waiting.. 100 BOX
  41. gadid 4
  42. ; ---------------- Start converting..
  43. xButton 210 80 90 14 Start
  44. gadid 5
  45. lvmulti first
  46. if $lv_file = ""
  47.    ezreq "No files selected!" OK ''
  48.    stop
  49. endif
  50. if $$LV_TYPE != FILE
  51.    ezreq 'Directories can not\nbe converted!\n\nTry again..\n' OK ""
  52.    stop 
  53. endif
  54. if $rp_from = ""
  55.    ezreq 'No "Replace:" defined!' OK ""
  56.    stop
  57. endif
  58. rp_flag = 0
  59. rp_destfile = ""
  60. if $rp_savemode = EXT
  61.    extract lv_file UNQUOTE rp_fname
  62.    appvar  rp_fname .rep
  63.    rp_destfile = \"$rp_fname\"
  64. endif
  65. gosub dir.rep disable
  66. update Dir.rep 4 'REP: $lv_file'
  67. launch 5 'Rep $lv_file $rp_from \"$rp_to\" $rp_destfile $rp_ci'
  68. ; Use of the launch command will allow the other GUIs running on
  69. ; this instance of Gui4Cli to go about their business normally
  70. xOnReturn 5
  71. update Dir.rep 4 'Finished.'
  72. lvmulti OFF            ; set selection off
  73. if $rp_flag != 0          ; check abort flag
  74.    rp_flag = 0            ; reset for next time
  75.    gosub dir.rep enable
  76.    stop
  77. endif
  78. lvmulti next            ; get next file
  79. if $lv_file = ""        ; no more files
  80.    lvdir refresh
  81.    gosub dir.rep enable
  82.    stop
  83. endif
  84. if $rp_savemode = EXT
  85.    extract lv_file UNQUOTE rp_fname
  86.    appvar  rp_fname .rep
  87.    rp_destfile = \"$rp_fname\"
  88. endif
  89. update Dir.rep 4 'REP: $lv_file'
  90. launch 5 'Rep $lv_file $rp_from \"$rp_to\" $rp_destfile $rp_ci'
  91. ; --------------- Cancel the rest of the files chosen.
  92. xButton 300 80 90 14 Stop
  93. setvar rp_flag 1
  94. ; --------------- Routines to disables & enable guis
  95. xRoutine disable
  96. guiwindow dir.gc wait
  97. setgad dir.rep 1 off
  98. setgad dir.rep 2 off
  99. setgad dir.rep 3 off
  100. setgad dir.rep 5 off
  101. setgad dir.rep 6 off
  102. xRoutine enable
  103. guiwindow dir.gc resume
  104. setgad dir.rep 1 on
  105. setgad dir.rep 2 on
  106. setgad dir.rep 3 on
  107. setgad dir.rep 5 on
  108. setgad dir.rep 6 on
  109. xOnFail
  110. gosub dir.rep enable
  111.